package com.yumingjaing.stream;

import com.yumingjaing.mockito.Student1;
import org.junit.Test;

import java.util.stream.Collectors;
import java.util.stream.Stream;

public class CollectDemo01 {
    @Test
    public void testCollect() {
        Stream<Student1> studentStream = Stream.of(
                new Student1("张三", 19, "男", "北京", 90.50),
                new Student1("李四", 20, "女", "上海", 80.50),
                new Student1("王五", 21, "男", "北京", 70.50),
                new Student1("赵六", 22, "女", "北京", 60.50),
                new Student1("孙七", 23, "男", "上海", 50.50)
        );
        // 一个字符串进行拼接
        //String collect = studentStream.map(Student::getName).collect(Collectors.joining("---"));
        //System.out.println(collect);
        //三个字符串进行拼接
        String collect1 = studentStream.map(Student1::getName).collect(Collectors.joining("---", "$", "$"));
        System.out.println(collect1);
    }
}